package com.puzzlebazar.client.squaregrid.view;

import com.puzzlebazar.client.squaregrid.model.SGModel;
import com.puzzlebazar.client.util.GridValidity;
import com.puzzlebazar.client.util.Recti;
import com.puzzlebazar.client.util.Vec2i;

public interface SGView extends GridValidity {
	
	/**
	 * Returns the position and size of the cell located at the specified row and column
	 * 
	 * @param loc Index of the column and row
	 * @return The cell position (in x,y) and size (in w,h) specified in pixels
	 * @throws Exception
	 */
	public abstract Recti getCellPositionAndSize( Vec2i loc ) throws Exception;

	/**
	 * Returns the pixel position of the vertex (the intersection of two grid lines)
	 * located at the specified row and column.
	 * 
	 * @param loc Index of the column and row (can be 1 more than the number of columns/rows)
	 * @return The vertex position
	 * @throws Exception
	 */
	public abstract Vec2i getVertexPosition( Vec2i loc ) throws Exception;	
	
	/**
	 * Gets the integer position of the vertex (the intersection of two grid lines)
	 * that is the closest to the X and Y position passed.
	 * 
	 * @param pixel The X/Y position in pixels
	 * @return The integer position (row, column) of the nearest vertex
	 */
	public abstract Vec2i getNearestVertex( Vec2i pixel );

	/**
	 * Sets a bleed area, in pixel, around the main widget
	 * 
	 * @param bleed The bleed area, in pixel (must be positive)
	 * @throws Exception 
	 */
	public abstract void setBleed(int bleed) throws Exception;
	
	/**
	 * Sets the size, in pixel, of the main widget excluding bleed area
	 * 
	 * @param outerSize The horizontal and vertical size in pixel, including bleed
	 * @throws Exception
	 */
	public void setOuterSize( Vec2i outerSize ) throws Exception;
	
	/**
	 * @return A rectangle indicating the internal position and size
	 */
	public abstract Recti getInnerRect();

	/**
	 * @return A vector indicating the number of rows and column in the grid
	 */
	public abstract Vec2i getGridSize();

	/**
	 * @return The puzzle model associated with that view
	 */
	SGModel getPuzzleModel();

}